(function () {
    const oEchart = echarts.init(document.getElementById('scatter01'));
    oEchart.setOption({
        title: {
            text: '散点图',
            left: 'center'
        },
        xAxis: {
            scale: true
        },
        yAxis: {
            scale: true
        },
        series: [
            {
                symbolSize: function (arg) { //散点大小设置
                    // console.log(arg, 'arg')
                    var weight = arg[0] //身高kg
                    var height = arg[1] / 100 //体重m
                    var bmi = weight / (height * height) //肥胖指数, 一般超过28即被认为是肥胖状态
                    if (bmi > 28) {
                        return 20
                    }
                    return 5
                },
                itemStyle: {
                    color: function (arg) { //散点颜色设置
                        // console.log(arg, 'arg')
                        var weight = arg.data[0]        //身高kg
                        var height = arg.data[1] / 100 //体重m
                        var bmi = weight / (height * height)
                        if (bmi > 28) {
                            return 'red'
                        }
                        return 'green'
                    }
                },
                type: 'scatter',
                data: [
                    [81.04, 150.0],
                    [61.95, 168.0],
                    [71.58, 173.0],
                    [81.81, 189.0],
                    [81.33, 191.0],
                    [71.66, 184.0],
                    [61.81, 173.4],
                    [61.33, 160.0],
                    [81.96, 154.0],
                    [61.82, 162.5],
                    [71.2, 179.1],
                    [71.2, 181.5],
                    [41.23, 193.0],
                    [71.83, 182.2],
                    [41.47, 172.0],
                    [51.33, 161.0],
                    [41.96, 154.0],
                    [71.24, 166.0],
                    [61.26, 172.0],
                    [81.84, 182.0],
                    [51.82, 197.0],
                    [51.68, 185.0]
                ],

            }
        ]
    })
})()